import type { ApiPagination, ApiPaginationParams } from '#types/utils'
import { formatDate } from '@vben/utils'
import { requestClient } from '../request'
import type {
    SaleSellerCreateOrdersListParams,
    SaleSellerCreateOrdersVo
} from './model/merchantReceivable'
// 商品管理
export default class MerchantReceivableApi {
    static get inst() {
        return (
            MerchantReceivableApi._inst ||
            (MerchantReceivableApi._inst = new MerchantReceivableApi())
        )
    }
    private static _inst: MerchantReceivableApi

    /**
     * 列表分页
     */
    getPageList(params: ApiPaginationParams<SaleSellerCreateOrdersListParams>) {
        if (params.checkStartTime && params.checkEndTime) {
            params.checkStartTime = `${formatDate(params.checkStartTime, 'YYYY-MM-DD')} 00:00:00`
            params.checkEndTime = `${formatDate(params.checkEndTime, 'YYYY-MM-DD')} 23:59:59`
        }
        // return {
        //     total: 1,
        //     records: [
        //         {
        //             id: 49,
        //             sellerUserId: 57,
        //             sellerName: '容宇航',
        //             taskId: 27,
        //             taskName: '东梓妍',
        //             authorId: 68,
        //             ordersNo: 'in deserunt cupidatat sed sit',
        //             goodsName: '石诗雨',
        //             goodsCode: '52',
        //             saleTime: '1988-06-08 12:15:08',
        //             saleNum: 88,
        //             salePrice: 130.05,
        //             extendUrl: 'https://glossy-guacamole.net/',
        //             prospectPrecent: 38,
        //             prospectPrice: 88.05,
        //             closeStatus: 1,
        //             checkTime: '1983-03-22 15:31:51',
        //             closeTime: '1982-09-15 23:24:14'
        //         },
        //         {
        //             id: 491,
        //             sellerUserId: 57,
        //             sellerName: '容宇航',
        //             taskId: 27,
        //             taskName: '东梓妍',
        //             authorId: 68,
        //             ordersNo: 'in deserunt cupidatat sed sit',
        //             goodsName: '石诗雨',
        //             goodsCode: '52',
        //             saleTime: '1988-06-08 12:15:08',
        //             saleNum: 88,
        //             salePrice: 130.05,
        //             extendUrl: 'https://glossy-guacamole.net/',
        //             prospectPrecent: 38,
        //             prospectPrice: 88.05,
        //             closeStatus: 0,
        //             checkTime: '1983-03-22 15:31:51',
        //             closeTime: '1982-09-15 23:24:14'
        //         }
        //     ]
        // }
        return requestClient.get<ApiPagination<SaleSellerCreateOrdersVo>>('/broker/sellIndex', {
            params
        })
    }

    /**
     * 结算
     */
    settlement(params: {
        /**
         * v
         */
        closeStatus: number
        /**
         * 结算id列表
         */
        ids: Array<number | string>
    }) {
        return requestClient.put<null>('/broker/sellCloseStatus', params)
    }
}
